package OBJECT;

public class ModthExercise02 {

//    编写类MyTools类，编写一个方法打印二维数组的数据
    public static void main(String[] args) {

        System.out.println("============");

        MyTools mt = new MyTools();
        mt.printArray(new int[][]{{1,2,3},{4,5,6},{7,8,9}});


        Personing ps = new Personing();
        ps.name = "张三";
        ps.age = "18";
        CopyPerson cp  = new CopyPerson();
        Personing p2 = cp.copyPerson(ps);
        System.out.println("p的属性 age= "+ps.age+"名字:"+ps.name);
        System.out.println("p2的属性 age= "+p2.age+"名字:"+p2.name);
    }

}
//编写一个copyPerson方法，接收一个Person类型的数组，返回一个Person类型的数组。
class CopyPerson{

    public Personing copyPerson(Personing p){
        Personing ping = new Personing();
        ping.name = p.name;
        ping.age = p.age;
        return ping;
    }

}

class Personing{
    String name;
    String age;

}


class  MyTools{
//   接收二维数组并打印
    public  void  printArray(int[][] arr){

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }

    }


}